﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetFrame
{
    /// <summary>
    /// 用户连接对象池
    /// </summary>
   public class UserTokenPool
    {
        /// <summary>
        /// 存储用户连接对象的栈
        /// </summary>
        private Stack<UserToken> mPool;
        public UserTokenPool(int max)
        {
            mPool = new Stack<UserToken>(max);
        }
        /// <summary>
        /// 取出一个连接对象
        /// </summary>
        public UserToken Pop()
        {
            return mPool.Pop();
        }
        /// <summary>
        /// 插入一个连接对象
        /// </summary>
        public void Push(UserToken token)
        {
            if (token != null)
            {
                mPool.Push(token);
            }
        }
        /// <summary>
        /// 当前剩余长度
        /// </summary>
        public int Size { get { return mPool.Count; } }
    }
}
